package com.quyunshuo.module.home.fragment.collection

import com.quyunshuo.androidbaseframemvvm.base.mvvm.m.BaseRepository
import com.quyunshuo.androidbaseframemvvm.network.HomeApiService
import com.quyunshuo.androidbaseframemvvm.network.bean.ArticleListRes2
import com.quyunshuo.androidbaseframemvvm.network.bean.BaseResponse
import com.quyunshuo.module.home.fragment.CallErrors
import com.quyunshuo.module.home.fragment.Result
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

/**
 * @author DBoy 2021/7/6 <p>
 * - 文件描述 :
 */
class CollectionRepository @Inject constructor() : BaseRepository() {

    @Inject
     lateinit var mAip:HomeApiService

    suspend fun getData(page: Int)=request<BaseResponse<ArticleListRes2>> {
        val response = mAip.listMyCollect(page)
        emit(response)

    }
    suspend fun getData1(page: Int)=request <Result<ArticleListRes2>>{
            val response = mAip.listMyCollect(page)
            if (response.data==null) {
                emit(Result.Error(CallErrors.ErrorEmptyData))
            }else{
                emit(Result.Success(response.data))

            }

    }
}